import { EventListener } from "../core/EventListener";
import { Constants } from "./Constants";


/** 游戏全局动态数据定义 */
export class GameDefine {
    public static isGamePaused: boolean = false; // 游戏是否暂停
    public static isGameOver: boolean = false; // 游戏是否结束

    /**  抽奖次数 */
    public static lotteryCount: number = 0;

    /** 金币数量 */
    private static _goldNum: number = 0;
    public static get goldNum(): number {
        return this._goldNum;
    }
    public static set goldNum(value: number) {
        this._goldNum = value;
        EventListener.emit('update_gold');

        // 1000、9000、20000 触发抽奖事件，只触发一次
        const lotteryThresholds = [1000, 3000, 6000];
        for (let i = 0; i < lotteryThresholds.length; i++) {
            if (this.lotteryCount === i && this._goldNum >= lotteryThresholds[i]) {
                this.lotteryCount++;
                console.log(`触发抽奖事件: ${lotteryThresholds[i]}`);
                EventListener.emit('lottery_chance');
                break;
            }
        }
    }

    /** 要塞等级 */
    private static _fortressLevel: number = 1;
    public static get FortressLevel(): number {
        return this._fortressLevel;
    }
    public static set FortressLevel(value: number) {
        this._fortressLevel = value;
        EventListener.emit(Constants.update_fortress_level);
    }

    public static mapMoveSpeed: number = 300; // 地图移动速度
}